package Index;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

/**
 * @author shkstart
 * @create 2021-12-01 19:25
 */
public class TreeNode implements Serializable {
    private String type;
    private String base;
    private String id;
    private String path;
    private ArrayList<TreeNode> children = new ArrayList<>();
    private Date date;

    public TreeNode() {
    }

    public TreeNode(String type, String id, String path, ArrayList<TreeNode> children, Date date) {
        this.type = type;
        this.id = id;
        this.path = path;
        this.children = children;
        this.date = date;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getBase() {
        return base;
    }

    public void setBase(String type) {
        if(type == "blob")
            this.base = "100644";
        if(type == "tree")
            this.base = "040000";
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getpath() {
        return path;
    }

    public void setpath(String path) {
        this.path = path;
    }

    public ArrayList<TreeNode> getChildren() {
        return children;
    }
    public void setChildren(ArrayList<TreeNode> children){
        this.children = children;
    }
    public void addChildren(TreeNode child) {
        children.add(child);
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }


    @Override
    public String toString() {
        return base + " " + type +" "+ id + " "  + path;
    }

}
